package main

import (
	"os"
	// "os.exec"
	"fmt"
	"os/exec"
	// "path"
	"path/filepath"
	"strconv"
	"time"
)

func main() {
	filePath, _ := exec.LookPath(os.Args[0])
	fmt.Println(filePath)

	// dirPath := filepath.Dir(os.Path).
	dirPath := filepath.Dir(filePath)
	fmt.Println(dirPath)
	timeStr := time.Now().Format("20060102")
	fmt.Println(timeStr)
	flgs := true
	path := dirPath + "\\" + timeStr
	count := 1
	for flgs {

		flgs, _ = PathExists(path)
		fmt.Println(flgs)

		if flgs {
			path = dirPath + "\\" + timeStr + "_" + strconv.Itoa(count)
			count += 1
			fmt.Println(path)
		}
	}

	os.MkdirAll(path, 0777)

	os.Exit(0)
}

func PathExists(path string) (bool, error) {
	_, err := os.Stat(path)
	if err == nil {
		return true, nil
	}
	if os.IsNotExist(err) {
		return false, nil
	}
	return false, err
}
